//给定单链表的头节点 head ，请反转链表，并返回反转后的链表的头节点。
 function ListNode(val, next) {
   this.val = (val===undefined ? 0 : val)
   this.next = (next===undefined ? null : next)
 }
var reverseList = function(head) {
    if(!head){return head;}
    let pre = null;
    let cur = head;
    let temp;
    while(cur){
        temp = cur.next;
        cur.next = pre;
        pre = cur;
        cur = temp;
    }
    return pre;
};
